home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / port11.zip / PORT.DOC < prev    next >
Text File  |  1991-03-14  |  12KB  |  359 lines

  1.  
  2.                                      PORT
  3.  
  4.                             The Port Twiddling Tool
  5.  
  6.                        By John De Armond (jgd@dixie.com)
  7.                          Rapid Deployment Systems, Inc.
  8.  
  9. Introduction
  10.  
  11. PORT is a tool written to facilitate working with I/O ports on the PC or
  12. Intel processor-based hardware.  It has many uses.  Among them:
  13.  
  14.     *    Debugging new hardware.
  15.     *    Reverse engineering old hardware.
  16.     *    Finding out where an adaptor card decodes its ports.
  17.     *    Otherwise manipulating I/O ports.
  18.  
  19. Among the capabilities:
  20.  
  21.     *    Read or write to a specified port.
  22.     *    Read or write and then wait for a specified byte or word pattern
  23.     *    Read or write in byte or word modes.
  24.     *    Enter or display data in either decimal or hex.
  25.     *    Repeatedly read or write a port - generate nice scoping patterns.
  26.     *    Repeatedly read or write and alternate between a specified bit
  27.              pattern and all zeros - generates even nicer scope patterns.
  28.     *    Increment or decrement port addresses while reading or writing
  29.             a specified bit pattern.
  30.     *    Submit commands from files.
  31.  
  32.  
  33. Starting PORT
  34.  
  35. Starting PORT is easy - just type "port" on the command line.  There are
  36. 2 optional arguments that you may specify if desired.  The first argument
  37. is interpreted as the port and the second is interpreted as the bit 
  38. pattern.  These must be specified in hex with no leading modifiers, eg,
  39.  
  40.     port 3b4 0111    DON'T use 0x3b4 or any other c-like notation
  41.  
  42. You can redirect a configuration file into PORT:
  43.  
  44.     port <config
  45.  
  46. This file should contain PORT commands just as if you had typed them
  47. from the command line.  PORT will execute the commands and then
  48. wait for keyboard input.
  49.  
  50.  
  51. The Command Line
  52.  
  53. When you invoke PORT, you will see something like this:
  54.  
  55.  
  56. PORT v1.0 03/04/91 by John De Armond.  (jgd@dixie.com)
  57.  
  58. Usage: port <port_address data>  Arguments are in hex
  59.  
  60. Commands:
  61.     
  62. r           read the port
  63. w           write the port
  64. e<xd>       Enter a byte (word in designated mode, hex or decimal)
  65. m<xdbw>     Mode (x=hex, d=dec, b=byte, w=word)
  66. t n         Toggle bit <n>
  67. c           Clear all bits
  68. s           Set all bits
  69. p           Set port address
  70. g<io>       Go In or Go Out - perform action continuously
  71. i           Increment port address one count
  72. d           Decrement port address one count
  73. q           Quit
  74. <           Redirect commands from a file
  75. ?           Help
  76.  
  77. While in "go out" mode, keys 0-f will toggle bits, <t> will cause the output
  78. to alternate between the byte pattern and all zeros.
  79.  
  80. Command (help-?): 
  81.  
  82. As you enter commands, you will see a display as follows:
  83.  
  84.                                      Bits
  85.                              5432 1098 7654 3210
  86. Port:  0000    Byte:  0100,  0000 0001 0000 0000  Mode= HEX  Data= BYTE
  87.  
  88. This display shows you the currently addressed port, the current bit
  89. pattern, the mode and the data size.  The "mode" refers to the display
  90. mode and can be either decimal or hex.  The mode is changed with the
  91. "mode" command or by the use of the modifiers "x" or "d" with the
  92. (E)nter command.  See below.
  93.  
  94.  
  95. Commands:
  96.  
  97. r - read the port
  98.  
  99.     This command executes a read on the specified port.  If the data
  100.     width is set to WORD, then the LSB is written to the specified port
  101.     and the MSB is written to port+1.  If the data width is set to BYTE,
  102.     the LSB is written to the specified port and the MSB is ignored.
  103.  
  104.     If the command is followed by a hex number, the command outputs the
  105.     byte specified with the "enter" command and then reads on the 
  106.     port looking for the byte pattern specified in the command.  This is
  107.     useful when testing latching ports or when testing devices that 
  108.     return a result code on the same port.
  109.  
  110.  
  111. w - write the port
  112.  
  113.     Same as the above except that a write is executed.
  114.  
  115.  
  116. e<xd> - Enter a byte or word
  117.  
  118.     This command allows you to enter a word or byte to be written to a port.
  119.     If the command is entered with no modifier, the default entry mode
  120.     is used.  A specific mode can be specified with the options "x" for HEX
  121.     mode or "d" for DECimal mode.  Examples:
  122.  
  123.     e 0100        (assumes the default mode is HEX)
  124.     ex 0100
  125.     ed 256
  126.  
  127.     If a mode "override" is specified as above, the override sticks; ie, 
  128.     it becomes the new default mode.
  129.  
  130.  
  131. m<xdbw> - Set the mode.
  132.  
  133.     This command allows you to specify new modes with no other effects.
  134.     This command is somewhat overloaded in that it applies to the word
  135.     size in addition to the HEX or DECimal modes.  This overloading
  136.     seems logical to this humble programmer and can be learned by those
  137.     for which it is not.
  138.  
  139.  
  140. t n - Toggle bit <n>
  141.  
  142.     This command allows you to toggle the setting of any bit in a word.
  143.     "n" is the bit position starting at zero.  Thus, the MSB is 15 and
  144.     the LSB is 0.  Example:
  145.  
  146.     t 3    sets the 4th bit (3rd bit numbering from 0) in the word.
  147.  
  148.  
  149. c - Clear all bits
  150.  
  151.     This one does what it says.  It clears all bits in the I/O word.
  152.     A shortcut for "ex 0".
  153.  
  154.  
  155. s - Set all bits
  156.  
  157.     Same as above except that it sets all bits.  A shortcut for "ex ffff".
  158.  
  159.  
  160. p - Set port address
  161.  
  162.     This command enters the port address to be manipulated.  It does not
  163.     have a hex or decimal override because it is not anticipated that
  164.     this command is a high usage one and and because people think of ports
  165.     in hex and because your humble programmer got lazy :-)  The entry mode is 
  166.     automatically the default mode.  Example:
  167.  
  168.     e 3e4
  169.  
  170.     
  171. g<io> - Go In or Go Out 
  172.  
  173.     This command makes PORT continuously input or output the specified word to 
  174.     the specified port until the <enter> key is pressed. There are several
  175.     options while the "go" mode that are explained below.
  176.  
  177.  
  178. i - Increment port address one count
  179.  
  180.     Just what it says, increase the port number by one.
  181.  
  182.  
  183. d - Decrement port address one count
  184.  
  185.     Again, just what it says.
  186.  
  187.  
  188. < - Redirect commands from a file
  189.  
  190.     This command directs PORT to read the specified file and interpret the
  191.     file's contents as typed commands.  These files are useful for storing
  192.     repeated data such as port addresses and for test patterns.  One can
  193.     output to a port and then read another, for example.  When interpreting
  194.     commands from a file, PORT goes into an abbreviated message mode so that
  195.     the screen is not cluttered and so that it will run faster.
  196.  
  197.  
  198. q - Quit
  199.  
  200.     Yep, exit the program.  No twiddling is done; the program simply exits.
  201.     If you want to restore a value to a port before exiting, be sure to
  202.     explicitly do it.
  203.  
  204. ? - Help
  205.  
  206.     Displays the help screen.
  207.  
  208.  
  209. The GO mode:
  210.  
  211. The GO mode is primarily designed to generate repetitive patterns on the
  212. I/O lines so you can observe them with an oscilloscope.  When 
  213. you enter the GO mode with a "gi" or "go" command, the specified byte
  214. is repeatedly output or input to the specified port as fast as the 
  215. computer can do it.  About 200 microseconds per cycle on a 16 mhz 386
  216. and a standard printer port.  
  217.  
  218. There are several options available while in the GO mode.  They are:
  219.  
  220. <    Decrement the port address one count.
  221.  
  222. >    Increment the port address one count.
  223.  
  224. digits 0-f
  225.     Toggle the state of the specified bit.
  226.  
  227. t    Enter "toggle" mode.  Only valid for OUT mode.  In this mode, on 
  228.     alternate cycles, the specified byte is output and on the other cycle, 
  229.     the value 0 is output.  This mode generates rapid scope patterns on
  230.     the data lines.
  231.  
  232. <enter>
  233.     Leave GO mode.
  234.  
  235. Note that there is a loop counter displayed on the screen.  For speed
  236. considerations, this display is not updated unless there is a display
  237. event.  If you want to monitor the progress of the looping, simply press 
  238. the space bar which makes the screen update but with no other effect.
  239.  
  240.  
  241. Rights
  242.  
  243.     This program is copyright 1991 by John De Armond.  Minimal rights reserved.
  244.  
  245.     You may not sell this program and if you redistribute it, you must
  246.     redistribute the self-extracting ZIP file which includes the 
  247.     source.  Source must always be available.  Other than this, you 
  248.     may do with this program what you like including modifying it
  249.     and/or incorporating portions of the code in other programs.
  250.  
  251.     If you modify